<template>
  <div class="orderManage">
    <split-pane split="horizontal" :default-percent="55" :max-Percent="80" v-on:resize="resize">
      <!-- 国际运输委托单管理 -->
      <template slot="paneL">
        <div class="top" ref="topType">
          <div class="form">
            <el-form ref="form" :model="form" :rules="rule" :inline="true" size="mini">
              <el-form-item prop="orderNum" label="订单号:">
                <el-input v-model="form.orderNum" style="width:170px" clearable></el-input>
              </el-form-item>
              <el-form-item prop="contractNo" label="合同号:">
                <el-input v-model="form.contractNo" style="width:170px" clearable></el-input>
              </el-form-item>
              <el-form-item prop="orderStatue" label="订单状态:">
                <el-select v-model="form.orderStatue" clearable style="width:170px">
                  <el-option v-for="(item, index) in statusList" :key="index" :value="item.rvLowValue" :label="item.rvCmeaning"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="start" label="下单时间:">
                <el-date-picker style="width:170px" v-model="form.start" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
              <el-form-item prop="end" label-width="3em" label="——">
                <el-date-picker style="width:170px" v-model="form.end" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
              <el-form-item prop label>
                <el-button type="primary" size="mini" @click="searchList">查 询</el-button>
              </el-form-item>
            </el-form>
          </div>
          <div class="btn">
            <buttonName @clickEvent="clickEventDom"></buttonName>
            <!--            <el-button plain size="mini" type="primary" v-if="isAuth('add')" @click="addOrder">新增订单计划</el-button>-->
            <!--            <el-button plain size="mini" type="primary" v-if="isAuth('edit')" @click="editOrder">修改订单计划</el-button>-->
            <!--            <el-button plain size="mini" type="primary" v-if="isAuth('cancle')" @click="delOrder">取消订单计划</el-button>-->
            <!--            <el-button plain size="mini" type="primary" v-if="isAuth('audit')" @click="audit">订单计划发布</el-button>-->
            <!--            <el-button plain size="mini" type="primary" v-if="isAuth('cancleAudit')" @click="cancelAudit">取消发布</el-button>-->
          </div>
          <div class="name">订单信息列表</div>
          <el-table
            :data="tableData"
            border
            class="orderPlanCss"
            :height="typeHeight"
            :header-cell-style="{ textAlign: 'center' }"
            highlight-current-row
            @row-click="rowClick"
            @row-dblclick="dbrowClick"
            @selection-change="handleSelectionChange"
          >
            <el-table-column :index="indexMethod" type="index" align="center" label="序号" width="50"></el-table-column>
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column align="left" prop="cmtContractNo" label="合同号" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" show-overflow-tooltip label="合同名称" width="160" prop="cmtContractName">
              <template slot-scope="scope">
                <span>{{ contractsCorrespondence[scope.row.cmtContractNo] }}</span>
              </template>
            </el-table-column>
            <el-table-column align="left" prop="attCode" label="订单号" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="center" prop="attStatusName" label="订单状态" show-overflow-tooltip width="180"></el-table-column>
            <el-table-column align="center" prop="attCreatetime" label="下单时间" show-overflow-tooltip width="180"></el-table-column>
            <el-table-column align="left" prop="adcConsigner" label="客户名称" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="adcLinkperson" label="联系人" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="adcLinkphone" label="联系电话" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="attCEtpName" label="供应商" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="adcSAddress" label="起始地" show-overflow-tooltip width="200"></el-table-column>
            <el-table-column align="left" prop="adcDAddress" label="目的地" show-overflow-tooltip width="200"></el-table-column>
            <el-table-column align="left" prop="gdsNames" label="货物名称" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="gdsWeight" label="订单总质量(T)" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="attAuditdiffering" label="供应商审核意见" show-overflow-tooltip width="200"></el-table-column>
            <!--            <el-table-column align="right" prop="rmbamount" label="订单金额(RMB)" show-overflow-tooltip-->
            <!--                             width="160"></el-table-column>-->
            <!--            <el-table-column align="left" prop="attLstmodifier" label="操作人" show-overflow-tooltip-->
            <!--                             width="160"></el-table-column>-->
            <!--            <el-table-column align="center" prop="attLstmodifytime" label="操作时间" show-overflow-tooltip-->
            <!--                             width="180"></el-table-column>-->
            <!--            <el-table-column align="left" prop="attRemark" label="备注" show-overflow-tooltip width="180"></el-table-column>-->
          </el-table>
          <div>
            <el-pagination
              class="pagination"
              small
              background
              ref="pagination"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="Pagination.currentPage"
              :page-sizes="Pagination.pageSizeList"
              :page-size="Pagination.pageSize"
              :layout="Pagination.layout"
              :total="Pagination.total"
            ></el-pagination>
          </div>

          <!--    </div>-->
        </div>
      </template>

      <template slot="paneR">
        <div class="bottom" ref="bottomCode">
          <div class="name">订单动态</div>
          <el-table :data="dynamicData" border :height="detlHeight" :header-cell-style="{ textAlign: 'center' }" highlight-current-row>
            <el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
            <el-table-column align="center" prop="optType" label="操作类型" show-overflow-tooltip width></el-table-column>
            <el-table-column align="center" prop="optStatusName" label="操作状态" show-overflow-tooltip width></el-table-column>
            <el-table-column align="center" prop="optCreator" label="操作人" show-overflow-tooltip width></el-table-column>
            <el-table-column align="center" prop="optCreatetime" label="操作时间" show-overflow-tooltip width></el-table-column>
            <!--            <el-table-column align="left" prop="optChanger" label="最后修改人" show-overflow-tooltip width=""></el-table-column>-->
            <!--            <el-table-column align="center" prop="optChangetime" label="最后修改时间" show-overflow-tooltip-->
            <!--                             width=""></el-table-column>-->
            <!--            <el-table-column align="left" prop="optRemark" label="备注" show-overflow-tooltip width=""></el-table-column>-->
          </el-table>
        </div>
      </template>
    </split-pane>

    <!-- 新增修改订单 对话框 -->
    <el-dialog
      :title="name"
      width="80%"
      :visible.sync="openDialog"
      v-if="openDialog"
      v-el-drag-dialog
      :close-on-press-escape="false"
      :before-close="close"
      :close-on-click-modal="false"
    >
      <div class="content">
        <div class="box">
          <div class="name">合同信息</div>
          <el-form :model="basicForm" :rules="basicRule" size="mini" ref="basicForm" label-width="auto">
            <!--            <el-row>-->
            <!--                <el-form-item label="合同名称：" prop="cmtContractNo">-->
            <!--                  <el-select clearable v-model="basicForm.cmtContractNo" :disabled="edit || see" style="width:100%"-->
            <!--                             @change="getDealInfo"  filterable  allow-create>-->
            <!--                    <el-option v-for="(item,index) in edit || see ? contracts : dealInfos" :key="index" :value="item.cmtContractNo"-->
            <!--                               :label="item.cmtContractName"></el-option>-->
            <!--                  </el-select>-->
            <!--                </el-form-item>-->
            <!--            </el-row>-->
            <el-row>
              <el-form-item label="合同名称：" prop="cmtContractName">
                <el-input
                  v-model="basicForm.cmtContractName"
                  :disabled="edit || see"
                  style="width:100%"
                  @focus="findContract"
                  clearable
                  placeholder="请选择合同名称"
                  label="合同名称"
                >
                  <i slot="suffix" class="el-input__icon el-icon-arrow-down" @click="findContract"></i>
                </el-input>
              </el-form-item>
            </el-row>
          </el-form>
        </div>
        <div class="box">
          <div class="name">基础信息</div>
          <el-form :model="basicForm" :rules="basicRule" size="mini" ref="basicForm" label-width="auto">
            <el-row>
              <el-col :span="8">
                <!--                糖厂、货主作为客户-->
                <el-form-item label="客户：" prop="attCltId ? attCltId : adcCltName">
                  <el-select
                    clearable
                    v-model="basicForm.attCltId ? basicForm.attCltId : basicForm.adcCltName"
                    disabled
                    style="width:100%"
                    @change="getName"
                    filterable
                    allow-create
                  >
                    <el-option v-for="(item, index) in customer" :key="index" :value="item.cltId ? item.cltId : item.cltName" :label="item.cltName"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <!--              <el-col :span="8">-->
              <!--                <el-form-item label="委托人：" prop="adcConsigner">-->
              <!--                  <el-input clearable v-model="basicForm.adcConsigner" :disabled="check || see"-->
              <!--                            maxlength="32"></el-input>-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->

              <el-col :span="8">
                <el-form-item label="供应商：" prop="attCEtpName">
                  <el-input clearable v-model="basicForm.attCEtpName" disabled maxlength="32"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="联系人：" prop="adcLinkperson">
                  <el-input clearable v-model="basicForm.adcLinkperson" disabled maxlength="32"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="联系电话：" prop="adcLinkphone">
                  <el-input clearable v-model="basicForm.adcLinkphone" disabled maxlength="16"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="手机：" prop="adcTel">
                  <el-input clearable v-model="basicForm.adcTel" disabled maxlength="11"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <!--            <el-row>-->
            <!--              <el-col :span="8">-->
            <!--                <el-form-item label="Email：" prop="adcEmail">-->
            <!--                  <el-input clearable v-model="basicForm.adcEmail" :disabled="check || see" maxlength="32"></el-input>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <!--              <el-col :span="8">-->
            <!--                <el-form-item label="QQ：" prop="adcQq">-->
            <!--                  <el-input clearable v-model="basicForm.adcQq" :disabled="check || see" maxlength="32"></el-input>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <!--              <el-col :span="8">-->
            <!--                <el-form-item label="微信：" prop="adcWechat">-->
            <!--                  <el-input clearable v-model="basicForm.adcWechat" :disabled="check || see" maxlength="32"></el-input>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <!--            </el-row>-->
            <el-row>
              <el-col :span="8">
                <el-form-item label="客户要求作业时间：" prop="attWrkdate">
                  <el-date-picker
                    clearable
                    :picker-options="startPickerOptions"
                    v-model="basicForm.attWrkdate"
                    value-format="yyyy-MM-dd"
                    :disabled="check || see"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="客户要求作业完成时间：" prop="attFinwrkdate">
                  <el-date-picker
                    clearable
                    :picker-options="endPickerOptions"
                    v-model="basicForm.attFinwrkdate"
                    value-format="yyyy-MM-dd"
                    :disabled="check || see"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="车型要求：" prop="adcVehicleRequirements">
                  <el-select clearable v-model="basicForm.adcVehicleRequirements" :disabled="check || see" style="width:100%">
                    <el-option v-for="(item, index) in carType" :key="index" :label="item.rvCmeaning" :value="item.rvLowValue"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <!--              <el-col :span="8">-->
              <!--                <el-form-item label="卸车费支付方：" prop="adcXcfzff">-->
              <!--                  <el-select clearable v-model="basicForm.adcXcfzff" :disabled="check || see" style="width:100%">-->
              <!--                    <el-option v-for="(item,index) in payer" :key="index" :label="item.rvCmeaning"-->
              <!--                               :value="item.rvLowValue"></el-option>-->
              <!--                  </el-select>-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->
              <el-col :span="8">
                <el-form-item label="订单结算方式：" prop="adcJsfhValue">
                  <el-select clearable v-model="basicForm.adcJsfh" style="width:48%" :disabled="check || see" @change="getPay">
                    <el-option v-for="(item, index) in payWay" :key="index" :label="item.rvCmeaning" :value="item.rvLowValue"></el-option>
                  </el-select>
                  <el-select clearable v-model="basicForm.adcJsfhValue" style="width:48%;margin-left: 4%;" :disabled="check || see">
                    <el-option v-for="(item, index) in payTime" :key="index" :label="item.rvCmeaning" :value="item.rvLowValue"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="车长要求：" prop="trkLong">
                  <el-select clearable v-model="basicForm.trkLong" :disabled="check || see" style="width:100%">
                    <el-option v-for="(item, index) in carLong" :key="index" :label="item.rvCmeaning" :value="item.rvLowValue"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <div class="concate">
          <div class="send box">
            <div class="name">发货方信息</div>
            <concate-form :cltId="basicForm.attCltId" :compForm="sendForm" :desc="true" :view="view" ref="sendForm"></concate-form>
          </div>
          <div class="box accept">
            <div class="name">收货方信息</div>
            <concate-form :cltId="basicForm.attCltId" :compForm="acceptForm" :desc="false" :view="view" ref="acceptForm"></concate-form>
          </div>
        </div>
        <div class="box">
          <div class="name">获取里程</div>
          <el-form :model="distanceForm" :rules="distanceRule" size="mini" ref="distanceForm" label-width="auto">
            <el-row>
              <el-col :span="8">
                <el-form-item label="里程：" prop="adcDistanced">
                  <el-input clearable v-model="distanceForm.adcDistanced" :disabled="check || see"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="时间：" prop="adcDistancedtime">
                  <el-input clearable v-model="distanceForm.adcDistancedtime" :disabled="check || see"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2">
                <el-link type="primary" @click="getJourney" :underline="false" v-if="!check && !see">获取里程</el-link>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <div class="box">
          <div class="name">货物信息</div>
          <el-form :model="basicForm" size="mini" :rules="goodsRule" ref="goodsRule">
            <el-table :data="basicForm.goodsForm" border height="150px" :header-cell-style="{ textAlign: 'center' }" highlight-current-row>
              <el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
              <el-table-column align="left" label="提货单编号" show-overflow-tooltip width>
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsBillno'" :rules="goodsRule.cddTakeNo">
                    <el-input clearable v-model="scope.row.gdsBillno"></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <!--              :disabled="check || see"-->
              <!--              <el-table-column align="center"  label="品牌" show-overflow-tooltip width="">-->
              <!--                <template slot-scope="scope">-->
              <!--                  <el-form-item :prop="'goodsForm.'+scope.$index+'.gdsType'" :rules="goodsRule.gdsType">-->
              <!--                    <el-select clearable style="width: 100%;" v-model="scope.row.gdsType" :disabled="check || see">-->
              <!--                      <el-option v-for="(item,index) in goods"-->
              <!--                                 :key="index"-->
              <!--                                 :value="item.rvLowValue"-->
              <!--                                 :label="item.rvCmeaning"></el-option>-->
              <!--                    </el-select>-->
              <!--                  </el-form-item>-->
              <!--                </template>-->
              <!--              </el-table-column>-->
              <el-table-column align="left" label="品牌" show-overflow-tooltip width>
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsType'" :rules="goodsRule.gdsType">
                    <el-input clearable v-model="scope.row.gdsType" disabled></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="left" label="货名" show-overflow-tooltip width>
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsName'" :rules="goodsRule.gdsName">
                    <el-input clearable v-model="scope.row.gdsName" :disabled="check || see"></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="left" label="件数" show-overflow-tooltip width="140">
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsQuantity'">
                    <el-input clearable v-model="scope.row.gdsQuantity" :disabled="check || see"></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="left" label="数量(吨)" show-overflow-tooltip width>
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsWeight'" :rules="goodsRule.gdsWeight">
                    <el-input clearable v-model="scope.row.gdsWeight" disabled></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="left" label="体积(m³)" show-overflow-tooltip width>
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsVolumn'">
                    <el-input clearable v-model="scope.row.gdsVolumn" :disabled="check || see"></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="left" label="运输单价(吨/元)" show-overflow-tooltip width="150">
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsPrice'" :rules="goodsRule.gdsPrice">
                    <el-input clearable v-model="scope.row.gdsPrice" disabled></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="left" label="备注" show-overflow-tooltip width="0">
                <template slot-scope="scope">
                  <el-form-item :prop="'goodsForm.' + scope.$index + '.gdsRemark'">
                    <el-input clearable v-model="scope.row.gdsRemark" :disabled="check || see || see"></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
            </el-table>
          </el-form>
        </div>
        <!--        <div class="box" v-if="check">-->
        <!--          <div class="name">发布信息</div>-->
        <!--          <el-form :model="auditForm" :rules="auditRule" size="mini" ref="auditForm" label-width="auto">-->
        <!--            <el-row>-->
        <!--              <el-col :span="20">-->
        <!--                <el-form-item label="发布内容：" prop="attAuditdiffering">-->
        <!--                  <el-input clearable v-model="auditForm.attAuditdiffering" type="textarea" :rows="2"></el-input>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--          </el-form>-->
        <!--        </div>-->
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close" size="mini">关闭</el-button>
        <el-button type="primary" @click="save" v-if="!see" size="mini">保存</el-button>
        <!--        <el-button type="primary" @click="rejectAction" v-if="check" size="mini">拒绝</el-button>-->
        <el-button type="primary" @click="auditAction" v-if="check" size="mini">发布</el-button>
      </div>
    </el-dialog>
    <!-- 合同下拉对话框 -->
    <el-dialog :modal-append-to-body="false" :modal="false" :visible.sync="dialogTableVisible" top="220px">
      <div class="form">
        <el-form ref="contractDown" :model="contractDown" :inline="true" size="mini">
          <el-form-item prop="cmtContractNo" label="合同号：">
            <el-input v-model="contractDown.cmtContractNo" clearable></el-input>
          </el-form-item>
          <el-form-item prop label>
            <el-button type="primary" size="mini" @click="searchContractList">查 询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="basicForm" ref="basicForm">
        <el-table
          :data="edit || see ? contracts : dealInfos"
          style="width:100%"
          border
          :height="maxHeight"
          max-height="300"
          :header-cell-style="{ textAlign: 'center' }"
          highlight-current-row
          @row-click="contractRowClick"
        >
          <el-table-column type="index" :index="indexMethod" align="center" label=" " width="50"></el-table-column>
          <el-table-column prop="cmtContractNo" label="合同号" sortable></el-table-column>
          <el-table-column prop="cmtContractName" label="合同名称"></el-table-column>
          <el-table-column prop="cmtPartyAName" label="托运方"></el-table-column>
          <el-table-column prop="cmtPartyBName" label="承运方"></el-table-column>
          <el-table-column prop="cmtSigningTime" label="签订时间"></el-table-column>
        </el-table>
      </div>
      <!-- 分页 -->
      <div class="block">
        <el-pagination
          ref="pagination"
          small
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="Pagination.currentPage"
          :page-sizes="Pagination.pageSizeList"
          :page-size="Pagination.PageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageInfo.pagetotal"
        ></el-pagination>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import paginationMixin from '@/mixins/pagination'
import resizeMixin from '@/mixins/resize'
import concateForm from './concate'
import isAuth from '@/mixins/buttonAuth'
import { orderInfo, orderOperaInfo, addOrEditOrderInfo, getRefCodesByType, getAuditUserList, EditOrderInfo, auditOrder, cancleOrderInfo } from '@/request/api'
import { PATTERN } from '@/utils/rules'
import { getSugarUserList } from '@/request/dropDown'
import { addOrderPlanInfo, EditOrderPlanInfo, getContractAll, getDealInfos, orderPlanInfo } from '@/request/orderSupervise/orderPlan'
import { releaseOrder, updateMore } from '@/request/internal/internalorder'
import scrollChange from '@/utils/onscroll'
import buttonName from '@/components/buttonName/button-name'
import { message } from '@/request/resetMessage'

export default {
  name: 'router.threeOrderSupervise',
  mixins: [paginationMixin, resizeMixin, isAuth],
  components: { concateForm, buttonName },
  data() {
    return {
      pageInfo:{
        pagetotal:'',
      },
      multipleSelection: [],
      form: {
        orderNum: '',
        contractNo:'',
        orderStatue: '',
        start: '',
        end: ''
      },
      contractDown: {
        cmtContractNo: ''
      },
      rule: {
        orderNum: [],
        orderStatue: [],
        start: []
      },
      statusList: [], //状态值
      maxHeight: -1,
      typeHeight: -1, //上方表格高度
      detlHeight: -1, //下方表格高度
      tableData: [],
      dynamicData: [], //动态数据
      currentData: {}, //单击选中数据
      viewData: {}, //双击选中数据

      //对话框----新增修改
      name: '',
      openDialog: false,
      edit: false, //编辑
      see: false, //查看
      check: false, //审核
      dialogTableVisible: false, //合同下拉对话框标志
      view: '0',
      distanceForm: {}, //里程信息
      distanceRule: {
        adcDistanced: [{ required: true, message: '请输入里程', trigger: 'blur' }],
        adcDistancedtime: [{ required: true, message: '请输入时间', trigger: 'blur' }]
      },
      basicForm: {}, //基础信息
      basicRule: {
        attCltId: [{ required: true, message: '请选择客户名称', trigger: 'change' }],
        adcConsigner: [{ required: true, message: '请输入委托人', trigger: 'blur' }],
        adcLinkperson: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
        adcLinkphone: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
        adcTel: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
        adcEmail: [
          { required: true, message: '请输入Email地址', trigger: 'blur' },
          {
            pattern: PATTERN.EMAIL,
            message: '请输入正确的Email地址',
            trigger: 'blur'
          }
        ],
        adcQq: [{ required: false, message: '请输入QQ', trigger: 'blur' }],
        adcWechat: [{ required: false, message: '请输入微信', trigger: 'blur' }],
        attWrkdate: [{ required: true, message: '请输入客户要求作业时间', trigger: 'blur' }],
        attFinwrkdate: [
          {
            required: true,
            message: '请输入客户要求作业完成时间',
            trigger: 'blur'
          }
        ],
        // adcVehicleRequirements: [{required: true, message: '请输入车型要求', trigger: 'blur'}],
        adcXcfzff: [{ required: true, message: '请输入卸车支付方', trigger: 'blur' }]
        // adcJsfhValue: [{required: true, message: '请输入订单结算方式', trigger: 'change'}],
        // trkLong: [{required: true, message: '请输入车长要求', trigger: 'blur'}],
      },
      contracts: [], //所有合同信息
      contractsCorrespondence: [], //合同对应信息，合同号对应合同名
      dealInfos: [], //合同下拉数据
      dealInfosOld: [], //合同下拉原始数据
      customer: [], //客户
      carType: [], //车型
      payer: [], //卸车支付
      payWay: [], //结算方式
      payTime: [], //结算方式
      carLong: [], //车长
      goods: [],
      sendForm: {}, //发货信息
      acceptForm: {}, //收货信息
      concateRule: {},
      goodsForm: [], //货物信息
      goodsRule: {
        // cddTakeNo: [{required: true, message: '请输入提货单编号', trigger: 'blur'}],
        gdsType: [{ required: true, message: '请输入货物品牌', trigger: 'blur' }],
        // gdsName: [
        //   { required: true, message: '请输入货物名称', trigger: 'blur' }
        // ],
        gdsQuantity: [{ required: true, message: '请输入货物件数', PATTERN: /^\d$/, trigger: 'blur' }],
        gdsWeight: [{ required: true, message: '请输入货物质量', trigger: 'blur' }],
        gdsVolumn: [{ required: true, message: '请输入货物体积', trigger: 'blur' }],
        gdsPrice: [{ required: true, message: '请输入货物价格', trigger: 'blur' }]
      },
      //审核信息
      auditForm: { attAuditdiffering: '' },
      auditRule: {}
    }
  },
  mounted() {
    let demandWrapper = document.querySelector('.orderPlanCss .el-table__body-wrapper')
    // 新增滚动条监听事件
    scrollChange(demandWrapper)
    this.refreshList()
    //订单状态
    getRefCodesByType('网络平台订单状态').then(res => {
      if (res.success === '1') {
        this.statusList = res.data
      }
    })
    getRefCodesByType('网络平台货物类型').then(res => {
      if (res.success === '1') {
        this.goods = res.data
      }
    })
    getRefCodesByType('卸车费用付方').then(res => {
      if (res.success === '1') {
        this.payer = res.data
      }
    })
    getRefCodesByType('车型_网络').then(res => {
      if (res.success === '1') {
        this.carType = res.data
      }
    })
    getRefCodesByType('车长_网络').then(res => {
      if (res.success === '1') {
        this.carLong = res.data
      }
    })
    getRefCodesByType('网络_结算方式').then(res => {
      if (res.success === '1') {
        this.payWay = res.data
      }
    })
    //客户下拉框
    getSugarUserList().then(res => {
      if (res.success === '1') {
        this.customer = res.data
      }
    })
  },
  created() {
    getContractAll().then(res => {
      this.contracts = res.data

      this.contracts.forEach(item => {
        this.$set(this.contractsCorrespondence, item.cmtContractNo, item.cmtContractName)
        // this.contractsCorrespondence[item.cmtContractNo] = item.cmtContractName)
      })
    })
    // this.resize = () => {
    //   this.maxHeight = this.$refs.inner.offsetHeight
    // }
    this.resize = () => {
      this.typeHeight = this.$refs.topType.offsetHeight - 140
      this.detlHeight = this.$refs.bottomCode.offsetHeight - 80
    }
  },
  computed: {
    startPickerOptions() {
      return {
        disabledDate: date => {
          if (!this.basicForm.attFinwrkdate) return false
          return date.getTime() > new Date(this.basicForm.attFinwrkdate).getTime()
        }
      }
    },
    endPickerOptions() {
      return {
        disabledDate: date => {
          if (!this.basicForm.attWrkdate) return false
          return date.getTime() < new Date(this.basicForm.attWrkdate).getTime()
        }
      }
    }
  },
  watch: {
    basicForm: {
      handler() {
        this.getPay(this.basicForm.adcJsfh)
      }
    }
  },
  methods: {
    handleSelectionChange(val) {
      this.multipleSelection = val
      console.log(this.multipleSelection)
    },
    clickEventDom(item) {
      if (item.mdlCode === 'add') {
        this.addOrder()
      } else if (item.mdlCode === 'edit') {
        this.editOrder()
      } else if (item.mdlCode === 'cancle') {
        this.delOrder()
      } else if (item.mdlCode === 'audit') {
        this.audit()
      } else if (item.mdlCode === 'cancelAudit') {
        this.cancelAudit()
      }
    },
    //拒绝
    rejectAction() {
      auditOrder({
        uuid: this.currentData.uuid,
        attStatus: 'SHJJ',
        attCode: this.currentData.attCode,
        attAuditdiffering: this.auditForm.attAuditdiffering
      }).then(res => {
        if (res.success === '1') {
          this.$message({
            type: 'success',
            message: '拒绝成功'
          })
          this.close()
        }
      })
    },
    //发布

    auditAction() {
      releaseOrder({
        uuid: this.currentData.uuid,
        attStatus: 'YFB',
        attCode: this.currentData.attCode,
        attAuditdiffering: this.auditForm.attAuditdiffering
      }).then(res => {
        if (res.success === '1') {
          this.$message({
            type: 'success',
            message: '发布成功'
          })
          this.close()
        }
      })
    },
    //获取结算类型
    getPay(name) {
      this.payTime = []
      if (this.basicForm.adcJsfh) {
        getRefCodesByType(name).then(res => {
          if (res.success === '1') {
            this.payTime = res.data
            if (this.payTime && this.payTime.length) {
              this.basicForm.adcJsfhValue = this.payTime[0].rvLowValue
            }
          }
        })
      } else {
        this.basicForm.adcJsfhValue = ''
      }
    },
    //获取客户name
    getName(name) {
      // this.basicForm.attCltName=name
      this.customer.forEach(item => {
        if (item.cltId === name) {
          this.basicForm.attCltName = item.cltName
          this.basicForm.attCEtpId = item.cltEptId
          this.basicForm.adcConsigner = item.cltName
          this.basicForm.adcLinkperson = item.cltContact
          this.basicForm.adcLinkphone = item.cltCtctel
          this.basicForm.adcTel = item.cltCtctel
        }
      })
    },
    //获取合同信息
    getDealInfo(no) {
      // this.basicForm.attCltName=name
      this.basicForm = {
        cmtContractNo: no
      }

      this.dealInfos.forEach(item => {
        if (item.cmtContractNo === no) {
          //基础信息
          this.basicForm.cmtContractName = item.cmtContractName //合同名称

          this.basicForm.cltEptId = item.cmtPartyA //客户企业id（糖厂id）
          this.basicForm.attCltName = item.cmtPartyAName
          this.basicForm.adcCltName = item.cmtPartyAName
          this.basicForm.attCEtpId = item.cmtPartyB //供应商企业id（供应商id）
          this.basicForm.attCEtpName = item.cmtPartyBName //供应商企业名称（供应商id）
          this.basicForm.adcConsigner = item.cmtPartyAName
          this.basicForm.adcLinkperson = item.cmtPartyAContacts
          this.basicForm.adcLinkphone = item.cmtPartyAPhone
          this.basicForm.adcTel = item.cmtPartyAPhone
          this.basicForm.attWrkdate = item.cmtStartDateShipment //客户要求作业时间(承运起始日期)
          this.basicForm.attFinwrkdate = item.cmtLatestLoadingDate //客户要求完成时间（最迟装货日期）

          this.basicForm.adcJsfh = '现结' //订单结算方式(默认现结)
          ;(this.basicForm.adcJsfhValue = 'DF'), //结算类型（默认到付）
          //发货方信息
          (this.sendForm.orShipper = item.cmtPartyAName), //发货方 (合同中没有)
          (this.sendForm.lxr = item.cmtPartyAContacts), //发货方联系人(合同中没有)
          (this.sendForm.lxdh = item.cmtPartyAPhone) //发货方联系方式
          this.sendForm.xxdz = item.cmtLoadingPlace //发货地详细地址
          this.getLongWei(item.cmtLoadingPlace, this.acceptForm)
          //收货方信息
          this.acceptForm.orReveivingparty = item.cmtConsigneeInformation //收货方
          this.acceptForm.lxr = item.cmtReceivingContact //收货方联系人
          this.acceptForm.lxdh = item.cmtReceivingPhone //收货方联系方式
          this.acceptForm.xxdz = item.cmtPlaceReceipt //收货方详细地址
          this.getLongWei(item.cmtPlaceReceipt, this.sendForm)

          //货物信息
          // gdsPrice: this.goodsForm[0].gdsPrice,
          //   gdsName: this.goodsForm[0].gdsName,
          //   gdsType: this.goodsForm[0].gdsType,
          //   gdsQuantity: this.goodsForm[0].gdsQuantity,
          //   gdsWeight: this.goodsForm[0].gdsWeight,
          //   gdsVolumn: this.goodsForm[0].gdsVolumn,
          //   gdsRemark: this.goodsForm[0].gdsRemark,
          this.basicForm.goodsForm = []
          item.consignmentDetailedVOs.forEach((ele, i) => {
            let newObj = {}
            //存放货物信息当前行的信息
            newObj.gdsBillno = ele.cddTakeNo //提单号
            newObj.gdsPrice = item.cmtTransportUnitPrice //运输单价
            newObj.gdsName = item.cmtGoodsName //货物品名
            newObj.gdsType = ele.cddBrand //品牌
            // this.goodsForm[i].gdsQuantity = 件数（合同没有）
            newObj.gdsWeight = ele.cddQuantity //数量（吨）{重量(t)}
            newObj.status = 1
            // this.goodsForm[i].gdsVolumn = 体积（合同没有）
            this.basicForm.goodsForm.push(newObj)
            // if(i === 0){
            //   this.basicForm.goodsForm.push(newObj);
            // }else {
            //   this.basicForm.goodsForm.push(newObj);
            // }
          })
        }
      })
    },
    //查询
    searchList() {
      this.refreshList()
    },
    //重写getList
    getList(currentPage, pageSize, updateTotal) {
      orderPlanInfo({
        attCode: this.form.orderNum,
        attStatus: this.form.orderStatue,
        cmtContractNo:this.form.contractNo,
        attCreatetimeStart: this.form.start,
        attCreatetimeEnd: this.form.end,
        PageIndex: this.Pagination.currentPage,
        PageSize: this.Pagination.pageSize
      }).then(response => {
        this.tableData = response.data
        updateTotal(Number(response.total))
        this.tableData.forEach(s => {
          s.gdsNames = ''
          s.goodsForm.map(m => {
            s.gdsNames += m.gdsName + ','
          })
        })
      })
      //客户下拉框
      getSugarUserList().then(res => {
        if (res.success === '1') {
          this.customer = res.data
        }
      })
      this.currentData = {}
    },

    //计算里程
    getJourney() {
      console.log(1111111111)
      var lng = this.sendForm.jd
      var lat = this.sendForm.wd
      var lng1 = this.acceptForm.jd
      var lat1 = this.acceptForm.wd

      if (!lng || !lat || !lng1 || !lat1) return

      this.searchTransit({ lng, lat }, { lng: lng1, lat: lat1 }, this.searchComplete, '北京')
    },
    searchTransit(startPoint, endPoint, searchComplete, map) {
      var BMap = window.BMap
      var start = new BMap.Point(startPoint.lng, startPoint.lat)
      var end = new BMap.Point(endPoint.lng, endPoint.lat)
      var transit = new BMap.DrivingRoute(map, {
        onSearchComplete: searchComplete
      })
      transit.search(start, end)
    },
    searchComplete(results) {
      var output,
        time = ''
      var plan = results.getPlan(0)
      time = plan.getDuration(true) //获取时间

      output = plan.getDistance(true) //获取距离

      this.distanceForm.adcDistanced = output
      this.distanceForm.adcDistancedtime = time
    },
    //保存编辑 新增
    save() {
      const basic = new Promise((resolve, reject) => {
        this.$refs.basicForm.validate(valida => {
          if (valida) {
            resolve()
          } else {
            reject()
          }
        })
      })

      const send = new Promise((resolve, reject) => {
        this.$refs.sendForm.validate(valid => {
          if (valid) {
            resolve()
          } else {
            reject()
          }
        })
      })

      const accept = new Promise((resolve, reject) => {
        this.$refs.acceptForm.validate(valid => {
          if (valid) {
            resolve()
          } else {
            reject()
          }
        })
      })

      const distance = new Promise((resolve, reject) => {
        this.$refs.distanceForm.validate(valid => {
          if (valid) {
            resolve()
          } else {
            reject()
          }
        })
      })

      const goods = new Promise((resolve, reject) => {
        // if(this.goodsForm.length>0){
        //   resolve()
        // }else{
        //   reject()
        // }
        this.$refs.goodsRule.validate(valid => {
          if (valid) {
            resolve()
          } else {
            reject()
          }
        })
      })

      const reg = /^\d{0,11}$/
      if (this.basicForm.goodsForm) {
        this.basicForm.goodsForm.forEach(item => {
          if (item.gdsQuantity && !reg.test(item.gdsQuantity)) {
            this.$message({
              showClose: true,
              message: '请输入正确的货物数量',
              type: 'error'
            })
            return
          }
        })
      }

      Promise.all([send, accept, distance, goods]).then(() => {
        if (this.edit) {
          //编辑
          EditOrderPlanInfo({
            cmtContractNo: this.basicForm.cmtContractNo, //合同号

            uuid: this.basicForm.uuid,
            attCltId: this.basicForm.attCltId, //客户ID
            attCltName: this.basicForm.attCltName, //attCltName
            attCEtpId: this.basicForm.attCEtpId, //客户企业ID
            attRemark: this.basicForm.attRemark, //备注
            odcSProvince: this.sendForm.province, //发货地省
            orDeliverypointcity: this.sendForm.city, //发货地市
            adcSAddress: this.sendForm.xxdz, //发货地详细地址
            odcDProvince: this.acceptForm.province, //收货方省
            orReveivingpartytelcity: this.acceptForm.city, //收货方市
            adcDAddress: this.acceptForm.xxdz, //收货方详细地址
            attWrkdate: this.basicForm.attWrkdate, //客户要求作业时间
            attFinwrkdate: this.basicForm.attFinwrkdate, //客户要求完成时间
            adcVehicleRequirements: this.basicForm.adcVehicleRequirements, //车型

            adcCltId: this.sendForm.adcCltId, //客户ID
            adcConsigner: this.basicForm.adcConsigner, //委托人
            adcLinkperson: this.basicForm.adcLinkperson, //联系人
            adcLinkphone: this.basicForm.adcLinkphone, //联系电话
            adcTel: this.basicForm.adcTel, //手机
            adcQq: this.basicForm.adcQq, //QQ,
            adcWechat: this.basicForm.adcWechat, //微信
            adcEmail: this.basicForm.adcEmail, //EMAIL
            orReveivingparty: this.acceptForm.orReveivingparty, //收货方
            orReveivingpartycontacts: this.acceptForm.lxr, //收货方联系人
            orReveivingpartytel: this.acceptForm.lxdh, //收货方联系方式
            orShipper: this.sendForm.orShipper, //发货方

            orShippercontacts: this.sendForm.lxr, //发货方联系人
            orShippertel: this.sendForm.lxdh, //发货方联系方式
            odcSArea: this.sendForm.district, //发货地区县
            odcDArea: this.acceptForm.district, //收货地区县
            trkLong: this.basicForm.trkLong, //车长要求
            adcSX: this.sendForm.jd, //X坐标--发
            adcSY: this.sendForm.wd, //Y坐标
            adcSSwrkdate: this.sendForm.adcSSwrkdate, //装车时间段（开始）
            adcSEwrkdate: this.sendForm.adcSEwrkdate, //装车时间段（结束）
            adcDX: this.acceptForm.jd, //X坐标---收
            adcDY: this.acceptForm.wd, //Y坐标
            adcDSfinwrkdate: this.acceptForm.adcDSfinwrkdate, //卸车时间段（开始）
            adcDEfinwrkdate: this.acceptForm.adcDEfinwrkdate, //卸车时间段（结束）
            adcXcfzff: this.basicForm.adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
            adcJsfh: this.basicForm.adcJsfh, //结算方式
            adcJsfhValue: this.basicForm.adcJsfhValue, //结算类型
            adcDistanced: this.distanceForm.adcDistanced, //里程
            adcDistancedtime: this.distanceForm.adcDistancedtime, //运输时间

            //货物
            goodsForm: this.basicForm.goodsForm
            // gdsPrice: this.goodsForm[0].gdsPrice,
            // gdsName: this.goodsForm[0].gdsName,
            // gdsType: this.goodsForm[0].gdsType,
            // gdsQuantity: this.goodsForm[0].gdsQuantity,
            // gdsWeight: this.goodsForm[0].gdsWeight,
            // gdsVolumn: this.goodsForm[0].gdsVolumn,
            // gdsRemark: this.goodsForm[0].gdsRemark,
          }).then(res => {
            if (res.success === '1') {
              this.$message({
                type: 'success',
                message: '修改数据成功',
                showClose: true
              })
              this.close()
            }
          })
        } else {
          //新增
          addOrderPlanInfo({
            cmtContractNo: this.basicForm.cmtContractNo, //合同号

            attCltId: this.basicForm.attCltId, //客户ID
            attCltName: this.basicForm.attCltName, //attCltName
            attCEtpId: this.basicForm.attCEtpId, //客户企业ID
            attRemark: this.basicForm.attRemark, //备注
            odcSProvince: this.sendForm.province, //发货地省
            orDeliverypointcity: this.sendForm.city, //发货地市
            adcSAddress: this.sendForm.xxdz, //发货地详细地址
            odcDProvince: this.acceptForm.province, //收货方省
            orReveivingpartytelcity: this.acceptForm.city, //收货方市
            adcDAddress: this.acceptForm.xxdz, //收货方详细地址
            attWrkdate: this.basicForm.attWrkdate, //客户要求作业时间
            attFinwrkdate: this.basicForm.attFinwrkdate, //客户要求完成时间
            adcVehicleRequirements: this.basicForm.adcVehicleRequirements, //车型

            adcCltId: this.sendForm.adcCltId, //客户ID
            adcConsigner: this.basicForm.adcConsigner, //委托人
            adcLinkperson: this.basicForm.adcLinkperson, //联系人
            adcLinkphone: this.basicForm.adcLinkphone, //联系电话
            adcTel: this.basicForm.adcTel, //手机
            adcQq: this.basicForm.adcQq, //QQ,
            adcWechat: this.basicForm.adcWechat, //微信
            adcEmail: this.basicForm.adcEmail, //EMAIL
            orReveivingparty: this.acceptForm.orReveivingparty, //收货方
            orReveivingpartycontacts: this.acceptForm.lxr, //收货方联系人
            orReveivingpartytel: this.acceptForm.lxdh, //收货方联系方式
            orShipper: this.sendForm.orShipper, //发货方
            orShippercontacts: this.sendForm.lxr, //发货方联系人
            orShippertel: this.sendForm.lxdh, //发货方联系方式
            odcSArea: this.sendForm.district, //发货地区县
            odcDArea: this.acceptForm.district, //收货地区县
            trkLong: this.basicForm.trkLong, //车长要求
            adcSX: this.sendForm.jd, //X坐标--发
            adcSY: this.sendForm.wd, //Y坐标
            adcSSwrkdate: this.sendForm.adcSSwrkdate, //装车时间段（开始）
            adcSEwrkdate: this.sendForm.adcSEwrkdate, //装车时间段（结束）
            adcDX: this.acceptForm.jd, //X坐标---收
            adcDY: this.acceptForm.wd, //Y坐标
            adcDSfinwrkdate: this.acceptForm.adcDSfinwrkdate, //卸车时间段（开始）
            adcDEfinwrkdate: this.acceptForm.adcDEfinwrkdate, //卸车时间段（结束）
            adcXcfzff: this.basicForm.adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
            adcJsfh: this.basicForm.adcJsfh, //结算方式
            adcJsfhValue: this.basicForm.adcJsfhValue, //结算类型
            adcDistanced: this.distanceForm.adcDistanced, //里程
            adcDistancedtime: this.distanceForm.adcDistancedtime, //运输时间

            //货物
            goodsForm: this.basicForm.goodsForm
            // gdsPrice: this.goodsForm[0].gdsPrice,
            // gdsName: this.goodsForm[0].gdsName,
            // gdsType: this.goodsForm[0].gdsType,
            // gdsQuantity: this.goodsForm[0].gdsQuantity,
            // gdsWeight: this.goodsForm[0].gdsWeight,
            // gdsVolumn: this.goodsForm[0].gdsVolumn,
            // gdsRemark: this.goodsForm[0].gdsRemark,
          }).then(res => {
            if (res.success === '1') {
              this.$message({
                type: 'success',
                message: '新增数据成功',
                showClose: true
              })
              this.close()
            }
          })
        }
      })
    },
    //关闭对话框----新增编辑查看
    close() {
      this.basicForm = {}
      this.openDialog = false
      this.refreshList()
    },
    //双击查看详情
    dbrowClick(row) {
      this.currentData = Object.assign({}, row)
      this.basicForm = this.currentData
      this.basicForm.cmtContractName = this.contractsCorrespondence[row.cmtContractNo]
      this.basicForm.attCltId = null
      //收货
      this.acceptForm = {
        orReveivingparty: this.currentData.orReveivingparty,
        lxr: this.currentData.orReveivingpartycontacts,
        lxdh: this.currentData.orReveivingpartytel,
        adcDSfinwrkdate: this.currentData.adcDSfinwrkdate,
        adcDEfinwrkdate: this.currentData.adcDEfinwrkdate,
        province: this.currentData.odcDProvince,
        city: this.currentData.orReveivingpartytelcity,
        district: this.currentData.odcDArea,
        xxdz: this.currentData.adcDAddress,
        jd: this.currentData.adcDX,
        wd: this.currentData.adcDY
      }
      //发货
      this.sendForm = {
        orShipper: this.currentData.orShipper,
        lxr: this.currentData.orShippercontacts,
        lxdh: this.currentData.orShippertel,
        adcSSwrkdate: this.currentData.adcSSwrkdate,
        adcSEwrkdate: this.currentData.adcSEwrkdate,
        province: this.currentData.odcSProvince,
        city: this.currentData.orDeliverypointcity,
        district: this.currentData.odcSArea,
        xxdz: this.currentData.adcSAddress,
        jd: this.currentData.adcSX,
        wd: this.currentData.adcSY
      }
      this.distanceForm = this.currentData
      this.goodsForm[0] = this.currentData
      this.auditForm = {}
      this.check = false
      this.view = '1'
      this.openDialog = true
      this.edit = false
      this.see = true
      this.name = '查看订单计划'
    },
    //单击
    rowClick(row) {
      setTimeout(() => {
        this.currentData = Object.assign({}, row)
        // this.$set(this.currentData.attCltName, row.adcCltName)
        // this.currentData.attCltName = row.adcCltName
        // this.currentData.adcConsigner = row.adcConsigner
        this.getDynamic()
      }, 300)
    },

    //合同对话框根据合同号模糊查询
    searchContractList() {
      getDealInfos({
        PageIndex: this.Pagination.currentPage,
        PageSize: this.Pagination.pageSize,
        cmtContractNo: this.contractDown.cmtContractNo
      }).then(res => {
        this.dealInfos = res.data
        console.log(this.dealInfos, 'this.dealInfos')
        // this.updatePaginationTotal(Number(res.total))
         this.pageInfo.pagetotal=Number(res.total)
      })
      // .this.contractDown.cmtContractNo
    },
    //合同对话框选中一行
    contractRowClick(row) {
      //this.rowData=row;
      this.dealInfos.map(item => {
        if (item.cmtContractNo == row.cmtContractNo) {
          this.basicForm.cmtContractNo = item.cmtContractNo
          this.basicForm.cmtContractName = item.cmtContractName
          this.getDealInfo(item.cmtContractNo)
        }
      })
      this.form.cmpName = row.fltName
      //刷新合同数据
      getDealInfos({
        PageIndex: this.Pagination.currentPage,
        PageSize: this.Pagination.pageSize
      }).then(res => {
        this.dealInfos = res.data
        // this.updatePaginationTotal(Number(res.total))
        this.pageInfo.pagetotal=Number(res.total)
      })
      this.dialogTableVisible = false
    },
    //获取动态信息
    getDynamic() {
      orderOperaInfo({
        attUuid: this.currentData.uuid
      }).then(res => {
        if (res.success === '1') {
          this.dynamicData = res.data
        }
      })
    },
    //取消发布
    cancelAudit() {
      if (Object.keys(this.currentData).length === 0) {
        this.$alert('请选择需要取消发布的订单计划！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }

      if (this.currentData.attStatus != 'YFB') {
        this.$alert('该订单不是已发布状态，无法取消发布！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      auditOrder({
        uuid: this.currentData.uuid,
        attStatus: 'QXFB',
        attCode: this.currentData.attCode,
        attAuditdiffering: ''
      }).then(res => {
        if (res.success === '1') {
          this.$message({
            type: 'success',
            message: '取消发布成功'
          })
          this.close()
        }
      })
    },
    //发布
    audit() {
      if (this.multipleSelection.length === 1) {
        this.currentData = this.multipleSelection[0]
        if (this.currentData.attStatus != 'CS' && this.currentData.attStatus != 'SHJJ') {
          this.$alert('该订单不是未发布状态，无法发布！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        this.basicForm = this.currentData
        this.basicForm.cmtContractName = this.contractsCorrespondence[this.currentData.cmtContractNo]
        //收货
        this.acceptForm = {
          orReveivingparty: this.currentData.orReveivingparty,
          lxr: this.currentData.orReveivingpartycontacts,
          lxdh: this.currentData.orReveivingpartytel,
          adcDSfinwrkdate: this.currentData.adcDSfinwrkdate,
          adcDEfinwrkdate: this.currentData.adcDEfinwrkdate,
          province: this.currentData.odcDProvince,
          city: this.currentData.orReveivingpartytelcity,
          district: this.currentData.odcDArea,
          xxdz: this.currentData.adcDAddress,
          jd: this.currentData.adcDX,
          wd: this.currentData.adcDY
        }
        //发货
        this.sendForm = {
          orShipper: this.currentData.orShipper,
          lxr: this.currentData.orShippercontacts,
          lxdh: this.currentData.orShippertel,
          adcSSwrkdate: this.currentData.adcSSwrkdate,
          adcSEwrkdate: this.currentData.adcSEwrkdate,
          province: this.currentData.odcSProvince,
          city: this.currentData.orDeliverypointcity,
          district: this.currentData.odcSArea,
          xxdz: this.currentData.adcSAddress,
          jd: this.currentData.adcSX,
          wd: this.currentData.adcSY
        }
        this.distanceForm = this.currentData
        this.goodsForm[0] = this.currentData
        this.auditForm = {}
        this.check = true
        this.view = '1'
        this.openDialog = true
        this.edit = false
        this.see = true
        this.name = '确认发布'
      } else if (this.multipleSelection.length > 1) {
        let count = 0
        for (let index = 0; index < this.multipleSelection.length; index++) {
          if (this.multipleSelection[index].attStatus != 'CS' && this.multipleSelection[index].attStatus != 'SHJJ') {
            count++
          }
        }
        if (count > 0) {
          this.$alert('存在订单不是未发布状态，无法发布！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        updateMore({ list: this.multipleSelection, stuas: 'YFB' }).then(res => {
          if (res.success == '1') {
            this.$message({
              type: 'success',
              message: '发布成功'
            })
            this.close()
          }
        })
      } else if (Object.keys(this.currentData).length !== 0) {
        if (this.currentData.attStatus != 'CS' && this.currentData.attStatus != 'SHJJ') {
          this.$alert('该订单不是未发布状态，无法发布！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        this.basicForm = this.currentData
        this.basicForm.cmtContractName = this.contractsCorrespondence[this.currentData.cmtContractNo]
        //收货
        this.acceptForm = {
          orReveivingparty: this.currentData.orReveivingparty,
          lxr: this.currentData.orReveivingpartycontacts,
          lxdh: this.currentData.orReveivingpartytel,
          adcDSfinwrkdate: this.currentData.adcDSfinwrkdate,
          adcDEfinwrkdate: this.currentData.adcDEfinwrkdate,
          province: this.currentData.odcDProvince,
          city: this.currentData.orReveivingpartytelcity,
          district: this.currentData.odcDArea,
          xxdz: this.currentData.adcDAddress,
          jd: this.currentData.adcDX,
          wd: this.currentData.adcDY
        }
        //发货
        this.sendForm = {
          orShipper: this.currentData.orShipper,
          lxr: this.currentData.orShippercontacts,
          lxdh: this.currentData.orShippertel,
          adcSSwrkdate: this.currentData.adcSSwrkdate,
          adcSEwrkdate: this.currentData.adcSEwrkdate,
          province: this.currentData.odcSProvince,
          city: this.currentData.orDeliverypointcity,
          district: this.currentData.odcSArea,
          xxdz: this.currentData.adcSAddress,
          jd: this.currentData.adcSX,
          wd: this.currentData.adcSY
        }
        this.distanceForm = this.currentData
        this.goodsForm[0] = this.currentData
        this.auditForm = {}
        this.check = true
        this.view = '1'
        this.openDialog = true
        this.edit = false
        this.see = true
        this.name = '确认发布'
      } else {
        this.$alert('请选择或者勾选需要发布的订单计划！', '提示', {
          confirmButtonText: '确定'
        })
      }
    },
    //取消订单
    delOrder() {
      if (Object.keys(this.currentData).length === 0) {
        this.$alert('请选择需要取消的订单计划！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      // if (this.currentData.attStatus != 'YFB') {
      //   this.$alert('已发布的订单无法取消！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      this.$alert('注意：你确定取消该订单吗？取消后不可恢复！', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        cancleOrderInfo({
          cmtContractNo: this.currentData.cmtContractNo,
          uuid: this.currentData.uuid,
          attCode: this.currentData.attCode
        }).then(res => {
          if (res.success === '1') {
            this.$message({
              type: 'success',
              message: '订单取消成功！'
            })
            this.close()
          }
        })
      })
    },
    //修改
    editOrder() {
      if (Object.keys(this.currentData).length === 0) {
        this.$alert('每次只能修改一个订单，你已选择0个', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.currentData.attStatus != 'CS' && this.currentData.attStatus != 'SHJJ') {
        this.$alert('未发布的订单才能编辑，无法编辑！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }

      this.basicForm = this.currentData
      this.basicForm.cmtContractName = this.contractsCorrespondence[this.currentData.cmtContractNo]
      //收货
      this.acceptForm = {
        orReveivingparty: this.currentData.orReveivingparty || '',
        lxr: this.currentData.orReveivingpartycontacts || '',
        lxdh: this.currentData.orReveivingpartytel || '',
        adcDSfinwrkdate: this.currentData.adcDSfinwrkdate || '',
        adcDEfinwrkdate: this.currentData.adcDEfinwrkdate || '',
        province: this.currentData.odcDProvince || '',
        city: this.currentData.orReveivingpartytelcity || '',
        district: this.currentData.odcDArea || '',
        xxdz: this.currentData.adcDAddress || '',
        jd: this.currentData.adcDX || '',
        wd: this.currentData.adcDY || ''
      }
      //发货
      this.sendForm = {
        orShipper: this.currentData.orShipper || '',
        lxr: this.currentData.orShippercontacts || '',
        lxdh: this.currentData.orShippertel || '',
        adcSSwrkdate: this.currentData.adcSSwrkdate || '',
        adcSEwrkdate: this.currentData.adcSEwrkdate || '',
        province: this.currentData.odcSProvince || '',
        city: this.currentData.orDeliverypointcity || '',
        district: this.currentData.odcSArea || '',
        xxdz: this.currentData.adcSAddress || '',
        jd: this.currentData.adcSX || '',
        wd: this.currentData.adcSY || ''
      }
      this.distanceForm = this.currentData
      this.goodsForm = this.currentData
      this.openDialog = true
      this.edit = true
      this.see = false
      this.check = false
      this.view = '0'
      this.name = '编辑订单计划信息'
    },
    //新增
    addOrder() {
      this.basicForm = {
        adcCltId: '',
        adcConsigner: '',
        adcLinkperson: '',
        adcLinkphone: '',
        adcEmail: '',
        adcQq: '',
        adcWechat: '',
        attWrkdate: '',
        attFinwrkdate: '',
        adcVehicleRequirements: '',
        adcXcfzff: '',
        adcJsfh: '',
        trkLong: ''
        // goodsForm : [{
        //   cddTakeNo: '',
        //   gdsType: '',
        //   gdsName: '',
        //   gdsQuantity: '',
        //   gdsWeight: '',
        //   gdsVolumn: '',
        //   dw: '',
        //   gdsRemark: ''
        // }]
      }
      //收货
      this.acceptForm = {
        orReveivingparty: '',
        lxr: '',
        lxdh: '',
        adcDSfinwrkdate: '',
        adcDEfinwrkdate: '',
        province: '',
        city: '',
        district: '',
        xxdz: '',
        jd: '',
        wd: ''
      }
      //发货
      this.sendForm = {
        orShipper: '',
        lxr: '',
        lxdh: '',
        adcSSwrkdate: '',
        adcSEwrkdate: '',
        province: '',
        city: '',
        district: '',
        xxdz: '',
        jd: '',
        wd: ''
      }
      this.distanceForm = {
        adcDistancedtime: '',
        adcDistanced: ''
      }
      this.goodsForm = [
        {
          gdsBillno: '',
          gdsType: '',
          gdsName: '',
          gdsQuantity: '',
          gdsWeight: '',
          gdsVolumn: '',
          dw: '',
          gdsRemark: ''
        }
      ]
      this.openDialog = true
      this.edit = false
      this.see = false
      this.check = false
      this.view = '0'
      this.name = '新增订单计划信息'
      getDealInfos({
        PageIndex: this.Pagination.currentPage,
        PageSize: this.Pagination.pageSize
      }).then(res => {
        this.dealInfos = res.data
        // this.updatePaginationTotal(Number(res.total))
        this.pageInfo.pagetotal=Number(res.total)
      })
    },

    getLongWei(address, ghf) {
      this.$jsonp('http:///geocoding/v3/', {
        address: address,
        output: 'json',
        ak: 'klVHCMMpLMNTWIknViZZOrKKEYVn8OOU'
      })
        .then(json => {
          ghf.jd = json.result.location.lng //经度
          ghf.wd = json.result.location.lat //纬度
        })
        .catch(err => {
          console.log(err, 'err')
        })
    },
    //findContract查询合同
    findContract() {
      this.dialogTableVisible = true
    }
  }
}
</script>
<style lang="scss" scoped>
.orderManage {
  padding: 15px 15px 12px;
  height: 100%;
  width: 100%;
  .top {
    width: 100%;
    height: 100%;

    table {
      max-width: 100%;
      font-size: 1.4rem;
      td {
        min-width: 170px;
        line-height: 3rem;
        padding-right: 3rem;
      }
    }
    .form {
      height: 30px;
      display: flex;
      // overflow-x: auto;
      flex: none;
    }

    .btn {
      height: 50px;
      line-height: 50px;
    }

    .name {
      font-size: 16px;
      line-height: 20px;
      font-weight: 500;
    }
    /*.table {*/
    /*  flex: 1;*/
    /*}*/
  }

  .bottom {
    width: 100%;
    height: 100%;

    .name {
      font-size: 16px;
      line-height: 20px;
      font-weight: 500;
    }
  }

  .concate {
    display: flex;
    justify-content: space-between;
    // padding:10px 0;
    .send {
      width: 49%;
    }

    .accept {
      width: 49%;
    }
  }

  .box {
    padding: 12px;
    position: relative;
    border: 1px solid rgb(29, 158, 233);
    border-radius: 5px;
    // height:300px;
    margin-bottom: 20px;

    .name {
      position: absolute;
      top: -20px;
      font-size: 16px;
      font-weight: 700;
      padding: 10px;
      line-height: 20px;
      background: #fff;
    }
  }
}
</style>
